/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.app.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Thuan
 */
@Entity
@Table(name = "SemesterOfBatch")
@NamedQueries({
    @NamedQuery(name = "SemesterOfBatch.findAll", query = "SELECT s FROM SemesterOfBatch s"),
    @NamedQuery(name = "SemesterOfBatch.findBySemesterId", query = "SELECT s FROM SemesterOfBatch s WHERE s.semesterOfBatchPK.semesterId = :semesterId"),
    @NamedQuery(name = "SemesterOfBatch.findByBatchId", query = "SELECT s FROM SemesterOfBatch s WHERE s.semesterOfBatchPK.batchId = :batchId"),
    @NamedQuery(name = "SemesterOfBatch.findByFromDate", query = "SELECT s FROM SemesterOfBatch s WHERE s.fromDate = :fromDate"),
    @NamedQuery(name = "SemesterOfBatch.findByToDate", query = "SELECT s FROM SemesterOfBatch s WHERE s.toDate = :toDate"),
    @NamedQuery(name = "SemesterOfBatch.findByDescription", query = "SELECT s FROM SemesterOfBatch s WHERE s.description = :description")})
public class SemesterOfBatch implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SemesterOfBatchPK semesterOfBatchPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fromDate")
    @Temporal(TemporalType.DATE)
    private Date fromDate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "toDate")
    @Temporal(TemporalType.DATE)
    private Date toDate;
    @Size(max = 2147483647)
    @Column(name = "description")
    private String description;
    @JoinColumn(name = "semesterId", referencedColumnName = "semesterId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Semester semester;
    @JoinColumn(name = "batchId", referencedColumnName = "batchId", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Batch batch;

    public SemesterOfBatch() {
    }

    public SemesterOfBatch(SemesterOfBatchPK semesterOfBatchPK) {
        this.semesterOfBatchPK = semesterOfBatchPK;
    }

    public SemesterOfBatch(SemesterOfBatchPK semesterOfBatchPK, Date fromDate, Date toDate) {
        this.semesterOfBatchPK = semesterOfBatchPK;
        this.fromDate = fromDate;
        this.toDate = toDate;
    }

    public SemesterOfBatch(int semesterId, int batchId) {
        this.semesterOfBatchPK = new SemesterOfBatchPK(semesterId, batchId);
    }

    public SemesterOfBatchPK getSemesterOfBatchPK() {
        return semesterOfBatchPK;
    }

    public void setSemesterOfBatchPK(SemesterOfBatchPK semesterOfBatchPK) {
        this.semesterOfBatchPK = semesterOfBatchPK;
    }

    public Date getFromDate() {
        return fromDate;
    }

    public void setFromDate(Date fromDate) {
        this.fromDate = fromDate;
    }

    public Date getToDate() {
        return toDate;
    }

    public void setToDate(Date toDate) {
        this.toDate = toDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Semester getSemester() {
        return semester;
    }

    public void setSemester(Semester semester) {
        this.semester = semester;
    }

    public Batch getBatch() {
        return batch;
    }

    public void setBatch(Batch batch) {
        this.batch = batch;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (semesterOfBatchPK != null ? semesterOfBatchPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SemesterOfBatch)) {
            return false;
        }
        SemesterOfBatch other = (SemesterOfBatch) object;
        if ((this.semesterOfBatchPK == null && other.semesterOfBatchPK != null) || (this.semesterOfBatchPK != null && !this.semesterOfBatchPK.equals(other.semesterOfBatchPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.app.model.SemesterOfBatch[ semesterOfBatchPK=" + semesterOfBatchPK + " ]";
    }

}
